﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MADSite
{
  public partial class SiteMaster : System.Web.UI.MasterPage
  {
    private int id = -1;
    TrainManagerClient trainManagerClient = new TrainManagerClient();
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!Request.Cookies.AllKeys.Contains("id"))
      {
        id = trainManagerClient.InitUser();
      }
      else
      {
        id = Int32.Parse(Request.Cookies["id"].Value);
      }
      HttpCookie cookie = new HttpCookie("id", id.ToString());
      Response.Cookies.Add(cookie);
    }

    protected void HeadLoginView_ViewChanged(object sender, EventArgs e)
    {

    }

    protected void HeadLoginStatus_LoggingOut(object sender, LoginCancelEventArgs e)
    {
      trainManagerClient.Logout(id);
    }
  }
}
